package com.kefu.call.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kefu.common.annotation.Permission;
import com.kefu.common.controller.AbstractBaseController;
import com.kefu.common.result.Result;
import com.kefu.common.result.ResultGenerator;
import com.kefu.common.vo.DeleteVo;
import com.kefu.common.vo.DetailVo;
import com.kefu.call.model.CurlProfile;
import com.kefu.call.service.CurlProfileService;
import com.kefu.call.vo.CurlProfileSearchVo;
import com.kefu.call.vo.CurlProfileInsertVo;
import com.kefu.call.vo.CurlProfileUpdateVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "驱动")
@RestController
@RequestMapping("call/curl_profile")
public class CurlProfileController extends AbstractBaseController {

    @Autowired
    private CurlProfileService curlProfileService;

//    @PostMapping("/add")
//    @ApiOperation(value = "新增驱动", notes = "新增驱动")
//    public Result<String> add(@Validated @RequestBody CurlProfileInsertVo curlProfileVo) {
//    	logger.info("新增驱动:{}", curlProfileVo);
//
//    	CurlProfile info = curlProfileVo.convert();
//        curlProfileService.save(info);
//        return ResultGenerator.genSuccessResult();
//    }
//
//    @PostMapping("/delete")
//    @ApiOperation(value = "删除驱动", notes = "删除驱动")
//    public Result<String> delete(@Validated @RequestBody DeleteVo delete) {
//    	logger.info("删除驱动:{}", delete);
//
//        curlProfileService.deleteById(delete.getId());
//        return ResultGenerator.genSuccessResult();
//    }

    @PostMapping("/update")
    @ApiOperation(value = "修改驱动", notes = "修改驱动")
    public Result<String> update(@Validated @RequestBody CurlProfileUpdateVo curlProfileVo) {
    	logger.info("修改驱动:{}", curlProfileVo);
    	
    	CurlProfile info = curlProfileVo.convert();
        curlProfileService.update(info);
        return ResultGenerator.genSuccessResult();
    }

    @PostMapping("/detail")
    @ApiOperation(value = "驱动详情", notes = "驱动详情")
    public Result<CurlProfile> detail(@Validated @RequestBody DetailVo detail) {

        CurlProfile curlProfile = curlProfileService.findById(detail.getId());
        return ResultGenerator.genSuccessResult(curlProfile);
    }

    @PostMapping("/list")
    @ApiOperation(value = "查询驱动", notes = "查询驱动")
    public Result<Page<CurlProfile>> list(@Validated @RequestBody CurlProfileSearchVo search) {    

        Page<CurlProfile> page = curlProfileService.searchLambdaPage(search);
        return ResultGenerator.genSuccessResult(page);
    }
}
